#include "engine.h"
#include "log.h"

#include "File/file.h"

#ifdef LEO_DESIGNER
log_t* editor_log=NULL;
#endif

string log_t::logstr;

#include <Windows.h>
struct simple_log_t:log_t
{
	simple_log_t()
	{
		changed=false;
	}
	bool changed;
	virtual void print(const char* text)
	{
		OutputDebugString(text);
		logstr+=text;
		file_t f;
		f.open("log.txt","wt");
		f.writestring(logstr);
		f.close();
		changed=true;
	}
} simple_log;
struct console_log_t:log_t
{
	virtual void print(const char* text)
	{
		PRINTF(text);
	}
} console_log;

void log_t::log(const char* str)
{
#ifdef LEO_DESIGNER
	if (editor_log)
		editor_log->print(str);
#else
//	console_log.print(str);
#endif
	simple_log.print(str);
}

bool log_t::log_changed()
{
	bool r=simple_log.changed;
	simple_log.changed=false;
	return r;
}
